﻿package com.wandian.controller
{
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.BankProxy;
	import com.wandian.model.socket.ServerPacketProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.view.mediator.GameRoomMediator;
	import com.wandian.view.mediator.MaskGameMediator;
	import com.wandian.view.mediator.account.AccountMediator;
	import com.wandian.view.mediator.bank.BankMediator;
	
	import flash.display.MovieClip;
	
	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.command.*;

    public class BankCommand extends SimpleCommand
    {
        private var _global:GameData;
        private var _mcPanel:MovieClip;

        public function BankCommand()
        {
            this._global = GameData.getInstance();
            return;
        }

        override public function execute(notification:INotification) : void
        {
            var _loc_4:Object = null;
            var _loc_5:Array = null;
            super.execute(notification);
            var _loc_2:* = facade.retrieveProxy(ServerPacketProxy.NAME) as ServerPacketProxy;
            var _loc_3:* = facade.retrieveProxy(BankProxy.NAME) as BankProxy;
            _loc_4 = notification.getBody();
            switch(notification.getName())
            {
                case CLZNoticeName.SHOW_BANK_PANEL:
                {
                    this.showPanel(notification);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_OPEN_REQ:
                {
                    _loc_3.requestOpenBank(_loc_4);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_DEPOSIT_GOLD_REQ:
                {
                    _loc_2.requestDeposit(_loc_4 as uint);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_WITHDRAW_GOLD_REQ:
                {
                    _loc_5 = _loc_4 as Array;
                    _loc_2.requestWithdraw(_loc_5[0], _loc_5[1]);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_TRANSFER_GOLD_REQ:
                {
                    _loc_5 = _loc_4 as Array;
                    _loc_2.requestTransfer(_loc_5[0], _loc_5[1], _loc_5[2]);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_MODIFY_REQ:
                {
                    _loc_2.requestModifyPW(_loc_4);
                    break;
                }
                case CLZNoticeName.BANK_COMMIT_RECORD_REQ:
                {
                    _loc_3.requestRecord(_loc_4 as int);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        private function showPanel(param1:INotification) : void
        {
            if (!this._mcPanel)
            {
                this._mcPanel = GameData.getMovieClip("BankPanel");
            }
            if (!Texas.I._mcWindosView.contains(this._mcPanel))
            {
                Texas.I._mcWindosView.addChildTo(this._mcPanel);
            }
            Texas.I._mcWindosView.centerXY(this._mcPanel);
            facade.registerMediator(new BankMediator(this._mcPanel));
            return;
        }

    }
}
